package com.owen.controller;

import com.owen.pojo.Resp;
import com.owen.service.UploadFile;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Controller
public class UploadController {

    @Autowired
    private UploadFile uploadFile;

    // 进入index页面的方法
    @GetMapping("/")
    public String index(){
        return "index";
    }

    // 执行文件上传
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    @ResponseBody
    public Resp<String> fileUpload(@RequestParam("file")MultipartFile file){
        // 调用文件上传的方法
        return uploadFile.upload(file);
    }

}